package de.kiltz.foo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect()
public class ZeitStopperInterceptor
{
    //                 void paket.Klasse.Methode(para)
    @Around("execution(* de.kiltz.foo.dao.*.*(..))")
    public Object invoke(ProceedingJoinPoint pjp) 
            throws Throwable
    {
    	long start = System.currentTimeMillis();
    	String methode = pjp.getSignature().getName();
    	String klasse = pjp.getTarget().getClass().getSimpleName();
        Object o = pjp.proceed();
        long zeit =  System.currentTimeMillis() - start;
        System.out.println(klasse+" : "+methode+ " ("+zeit+" ms.)");
        return o;
    }
    
    @AfterReturning(returning="o", value="execution(* de.kiltz.foo.dao.*.*(..))")
    public void nachDerMethode(Object o)
    {
        System.out.println("Nach Methode "+o);
    }
}
